1. Field of the Invention
The present invention generally relates to graphics processing and, more specifically, to rendering using multiple render target sample masks.
2. Description of the Related Art
A graphics processing pipeline performs the collection of processing steps performed to transform 3-D images into rendered 2-D images. As part of transforming a 3-D image, the image is divided into a two dimensional array of pixels, each representing a different image location. The dimensions of this two dimensional array of pixels defines the resolution of the rendered 2-D image. Since the viewer's ability to resolve images may exceed the resolution of the rendered 2-D image, visual artifacts produced during the rendering may reduce the realism of the 2-D image. For example, if an edge of a triangle is not aligned with a vertical or horizontal line of pixel locations, the edge will exhibit a jagged, stair-step appearance in the rendered 2-D image. Various techniques may be used to reduce the appearance of such errors and visual artifacts (e.g., smooth the appearance of jagged edges), thereby improving the realism of the rendered images.
One approach to improving the realism of rendered images is through multisampling operations. In multisampling, each pixel is subdivided into samples, and a pixel shader (included in the graphics processing pipeline) processes each pixel individually. For each pixel, the pixel shader computes a sample color value at each the covered samples (i.e., the set of samples that are covered by a particular graphics primitive). Subsequently, the pixel shader resolves these sample colors into a single pixel color value. Finally, the single pixel color value is broadcast to each of the covered samples, which results in the same color value being assigned to each sample in the pixel that is covered by the graphics primitive. The raster operations units (also include in the graphics processing pipeline) then uses the single pixel color associated with this graphics primitive to update the overall pixel color. One limitation to this approach is that the quality of the image may still be unacceptably low.
For example, suppose that a pixel were to include four samples that were all covered by a first triangle (a graphics primitive). Further, suppose that two left-most samples were covered by blue portions of the first triangle and the two right-most samples were covered by yellow portions of the first triangle. As part of rendering the first triangle, the pixel shader would assign a green color (a mixture of blue and yellow) to each of the four samples. By resolving the sample colors in this fashion, per-sample information would be lost. For instance, information that the two left-most samples were covered by blue portions of the first triangle would longer be available. Suppose further that a second triangle were to be subsequently rendered on top (i.e., at a depth closer to the viewer) of the first triangle. And suppose that the two right-most samples were covered by blue portions of the second triangle, but the two left-most samples were not covered by the second triangle. As part of rendering the second triangle, the pixel shader would assign a blue color to the two right-most samples, but would not assign a color to the two left-most samples. The ROP unit would then update the overall pixel color to consider both the contributions of the first triangle and the second triangle. Consequently, the final processed color of the pixel would be a mixture of the green color and the blue color. However, after the addition of the second triangle, the color values at each of the sample locations included in the pixel would be blue in the 3-D image. Thus, using multisampling to create the rendered 2-D image would distort the true color of the 3-D image.
Another approach to improving the realism of rendered images is supersampling. In supersampling, the pixel shader computes an individual color value for each sample and does not resolve the sample color values into a single pixel color value. One drawback to supersampling is that the pixel shader processes each sample individually, thus the entire pixel shading calculation is performed per sample. In particular, time consuming operations performed by the pixel shader, such as texture fetches, are performed per sample. Typically, the majority of the execution time required during rendering is spent performing pixel shading operations. Consequently, supersampling can lead to inefficiencies in the graphics processing pipeline and reduce the rendering frame rate. The reduced rendering frame rate may be unacceptable for many graphics-based software applications such as video games.
As the foregoing illustrates, what is needed in the art is a more effective technique to improve the realism of rendered images.